package com.moli.iov.his.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moli.iov.his.mapper.ReportTotalOnlineMapper;
import com.moli.iov.his.model.po.ReportTotalOnline;
import com.moli.iov.his.service.IReportTotalOnlineService;
import com.moli.iov.his.util.HisUtil;
import com.moli.iov.rest.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * <p>
 * 全网在线车辆统计 服务实现类
 * </p>
 *
 * @author sy
 * @since 2018-12-04
 */
@Service("reportTotalOnlineService")
public class ReportTotalOnlineServiceImpl extends ServiceImpl<ReportTotalOnlineMapper, ReportTotalOnline> implements IReportTotalOnlineService {

    @Autowired
    private ReportTotalOnlineMapper reportTotalOnlineMapper;

    @Override
    public RestResponse saveReportTotalOnline(ReportTotalOnline reportTotalOnline) {

        boolean save = save(reportTotalOnline);
        return save ? RestResponse.success() : RestResponse.failure("新增在网车辆统计失败！");
    }

    @Override
    public List<ReportTotalOnline> queryOnlineReport() throws Exception {

        List<ReportTotalOnline> reportTotalOnlines = reportTotalOnlineMapper.queryOnlineReport();
        List<ReportTotalOnline> ret = HisUtil.getOnlineDateReport(reportTotalOnlines);
        return ret;


//        List<ReportTotalOnline> reportTotalOnlines = reportTotalOnlineMapper.queryOnlineReport();
//        return reportTotalOnlines;
    }



    @Override
    public List<ReportTotalOnline> queryOnlineReportByTime(Map map) throws Exception {
        return reportTotalOnlineMapper.queryOnlineReportByTime(map);
    }
}
